package FIT::Fixture::Column;

use FIT::Class;
use FIT::TypeAdapter;

extends 'FIT::Fixture::Base';

# any column fixture can have a description column which is normally ignored
has description  => (is => 'rw', isa => 'Str');

around do_rows => sub { $next->( $self, shift->next_row ) }; # skip headings

augment do_cell => sub {
    my $cell = shift;
    inner;

    my $adapter = $self->make_adapter($cell);

    my $method = 'parse_and_'. ($cell->fit_is_output_cell? 'check': 'set');
    $adapter->$method($cell);
};

sub make_adapter {
    my $cell = shift;
    return adapt adaptee => $self, name => $cell->column_heading;
}

sub reset   {} # called before each row, by Execute handler
sub execute {} # called before 1st output column, xor after each row

override row_handlers  => sub { (super, 'Execute') };
override cell_handlers => sub { (super, 'Execute') };

